# encoding: utf-8

from django.contrib import admin
from django.conf.urls import patterns, include, url

from wxxiaohello import views, edits
from django.conf import settings
from django.views.generic import TemplateView
admin.autodiscover()
urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'pdjtest.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    # views.py===========>
    
    url(r'^$', views.index, name="index"),
     # #首页博客列表
    url(r'^index/$', views.index, name="index"),
    url(r'^index/(?P<pn>\d+)/$', views.index_pn, name="index"),
    
    url(r'^index.html$', views.index, name="index"),
    url(r'^blog.html$', views.index, name="blog"),
    
    # #获取博客具体内容展示 /blog/33/
    url(r'^blog/(?P<blog_id>\d+)/$', views.blog, name="blog"),
    
    # #查找博客 
    url(r'^search/$', views.search, name="search"),
    
    # #获取标签相关的博客 /tag/标签/
    url(r'^tag/(?P<tag_id>\d+)/$', views.tag_blog, name="tag"),
    url(r'^tag/(?P<tag_id>\d+)/(?P<pn>\d+)/$', views.tag_blog_pn, name="tag"),
    
    # #获取对应月份下的博客 /filing/time/
    url(r'^filing/(?P<year>\d+)/(?P<month>\d+)/$', views.filing, name="filing"),
    url(r'^filing/(?P<year>\d+)/(?P<month>\d+)/(?P<pn>\d+)$', views.filing_pn, name="filing"),
    # # 查询归档列表
    # ## url(r'^filing_list/$',views.filing_list,name="filing_list"),
    # ## url(r'^group_list/$',views.group_list,name="group_list"),
    
    # # 查询侧边栏
    url(r'^sidebar/$', views.sidebar, name="sidebar"),
    
     # #根据分组获取文章
    url(r'^group/(?P<classify_id>\d+)/$', views.group_blog, name="group"),
    url(r'^group/(?P<classify_id>\d+)/(?P<pn>\d+)/$', views.group_blog_pn, name="group"),
    
    # admin page
    url(r'^login/', views.login, name="login"),
    url(r'^accounts/login/', views.login, name="login"),
    url(r'^login.html', views.login, name="login"),
    url(r'^logout/', views.logout, name="logout"),
    
    url(r'^about.html$', views.about, name="about"),
    # # edits.py===================>
    # ##控制台首页
    url(r'^edit/$', edits.edit, name="edit"),
    # #留言板
    url(r'^edit/add_message/$', edits.add_message, name="add_message"),
    # #请求新建一篇博客
    url(r'^edit/create_new_blog/$', edits.create_new_blog, name="create_new_blog"),
    # #保存新建的博客
    url(r'^edit/save_new_blog/$', edits.save_new_blog, name="save_new_blog"),
    # #请求编辑某篇博客内容,url示例 ( /get_edit_blog/12/ )
    url(r'^edit/get_edit_blog/(?P<blog_id>\d+)/$', edits.get_edit_blog, name="get_edit_blog"),
    # #保存编辑后的博客
    url(r'^edit/save_update_blog/$', edits.save_update_blog, name="save_update_blog"),
    # #后台获取已发布文章列表
    url(r'^edit/get_released_blog_list/$', edits.get_released_blog_list, name="get_released_blog_list"),
    # #后台获取草稿文章列表
    url(r'^edit/get_draft_blog_list/$', edits.get_draft_blog_list, name="get_draft_blog_list"),
    # #后台删除某篇文章
    url(r'^edit/delete_blog/$', edits.delete_blog, name="delete_blog"),
    # #获取文章分类列表
    url(r'^edit/get_classify_list/$', edits.get_classify_list, name="get_classify_list"),
    # ##删除文章分类
    url(r'^edit/delete_classify/$', edits.delete_classify, name="delete_classify"),
    # #添加文章分类
    url(r'^edit/add_classify/$', edits.add_classify, name="add_classify"),
    # #修改文章分类
    url(r'^edit/update_classify/$', edits.update_classify, name="add_classify"),
    # #获取评论列表
    url(r'^edit/get_message_list/$', edits.get_message_list, name="get_message_list"),
    # #删除评论
    url(r'^edit/delete_message/$', edits.delete_message, name="delete_message"),
    
    url(r'^edit/clear_cache/$', edits.clear_cache, name="clear_cache"),
  
    # admin in here
    url(r'^admin/', include(admin.site.urls)),
      
    # static urlpatterns
    # Static files (CSS, JavaScript, Images)
    url(r'^ueditor/(?P<path>.*)$', 'django.views.static.serve', {'document_root':settings.STATIC_ROOT + "/ueditor/"}),
    url(r'^css/(?P<path>.*)$', 'django.views.static.serve', {'document_root':settings.STATIC_ROOT + "/css/"}),
    url(r'^fonts/(?P<path>.*)$', 'django.views.static.serve', {'document_root':settings.STATIC_ROOT + "/fonts/"}),
    url(r'^js/(?P<path>.*)$', 'django.views.static.serve', {'document_root':settings.STATIC_ROOT + "/js/"}),
    url(r'^images/(?P<path>.*)$', 'django.views.static.serve', {'document_root':settings.STATIC_ROOT + "/images/"}),
    # #robots.txt
    (r'^robots\.txt$', TemplateView.as_view(template_name="robots.txt", content_type="text/plain")),
    
)

handler404 = views.NF404_viewer
handler500 = views.NF500_viewer


